package com.neiquan.backstage.resourec_manage.imp;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.neiquan.backstage.common.util.ExtraSpringHibernateTemplate;
import com.neiquan.backstage.pub.bsc.dao.po.Payment;
import com.neiquan.backstage.resourec_manage.PaymentService;

@Service
public class PaymentServiceImp implements PaymentService {
	private static Class<?> poc = Payment.class;
	@Autowired
	private ExtraSpringHibernateTemplate extraSpringHibernateTemplate;
	
	@Override
	public List<Payment> queryByEentrepreneurId(int entrepreneurId) {
		// TODO Auto-generated method stub
		List<Payment> listP= (List<Payment>) extraSpringHibernateTemplate.getHibernateTemplate().find("From Payment where entrepreneurId=? and status=?", entrepreneurId,Payment.PAY_SUCCEE);
		return listP;
	}
	
	@Override
	public void add(Payment entity) {
		// TODO Auto-generated method stub
		extraSpringHibernateTemplate.getHibernateTemplate().save(entity);
	}

	@Override
	public Payment queryById(int id) {
		// TODO Auto-generated method stub
		return extraSpringHibernateTemplate.findFirstOneByPropEq(poc, "PaymentId", id);
	}

	@Override
	public void updata(Payment entity) {
		// TODO Auto-generated method stub
		extraSpringHibernateTemplate.getHibernateTemplate().update(entity);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Payment> queryAll() {
		// TODO Auto-generated method stub
		return (List<Payment>) extraSpringHibernateTemplate.findAll(poc);
	}

	@Override
	public Payment querByUUID(String uUID) {
		// TODO Auto-generated method stub
		return extraSpringHibernateTemplate.findFirstOneByPropEq(poc, "UUID", uUID);
	}
}
